import java.util.Scanner;


public class CANTON {
	public static void main (String args[]) {
		Scanner in = new Scanner(System.in);
		
		// Enter number of testcases 
		int testcases = in.nextInt();
		
		// find the cantor's term for all testcases
		while (testcases-- > 0) {
			int number = in.nextInt();
			
			// find the diagonal for the number
			int diagonal = (int) Math.ceil(-.5 + (Math.sqrt(8*number+1))/2);
			
			//find the end point of the above diagonal
			int endPoint = (diagonal * (diagonal + 1))/2 - number;
			//int difference = endPoint - number;
			
			// check whether diagonal is even or odd.
			if ((diagonal % 2) == 0) {
				System.out.println("TERM " + number + " IS " + (diagonal - endPoint) + "/" + (1 + endPoint));
			} else {
				System.out.println("TERM " + number + " IS " + (1 + endPoint) + "/" + (diagonal - endPoint));
			}
		}
	}
}
